package com.learn._2list;

/**
 * 用多重链表实现矩阵
 * @param <T>
 */
public class Matrix<T> {


    private Node<T> allHead = new Node<>();
    private Node<T> lineLastHead = allHead;
    private Node<T> colLastHead = allHead;
    private int line;
    private int col;

    private class Node<T>{
        T value;
        Node<T> right;
        Node<T> down;
    }

    public Matrix(int line,int col){
        this.line = line;
        this.col = col;

        for(int i = 0;i < line;i ++){
            Node<T> lineHead = new Node<>();
            lineLastHead.down = lineHead;
            lineLastHead = lineHead;
        }
        lineLastHead.down = allHead;

        for(int i = 0;i < col; i ++){
            Node<T> colHead = new Node<>();
            colLastHead.right = colHead;
            colLastHead = colHead;
        }
        colLastHead.right = allHead;
    }


}
